home *** CD-ROM | disk | FTP | other *** search
/ 3D Games - Real-time Rend…ng & Software Technology / 3D Games - Real-time Rendering & Software Technology.iso / flysdk / plugin / ship / game.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-03-16  |  5.3 KB  |  268 lines

  1. #include "..\..\lib\Fly3D.h"
  2. #include "..\weapon\weapon.h"
  3.  
  4. #define SHIP_FLAG3_INVISIBLE 0x10000
  5. #define SHIP_FLAG3_INVENSIBLE 0x20000
  6. #define SHIP_MAXAB_SPEEDBOOST 5000
  7.  
  8. #define FLYMP_MSG_POS 9180
  9. #define FLYMP_MSG_KILL 9181
  10. #define FLYMP_MSG_EXPLODE 9182
  11. #define FLYMP_MSG_DAMAGE 9183
  12. #define FLYMP_MSG_POWERUPMOVE 9184
  13. #define FLYMP_MSG_POWERUPGET 9185
  14.  
  15. void init_multiplayer();
  16. void mp_message(int from,mp_msg *msg);
  17.  
  18. enum 
  19.     TYPE_SHIP=0x200,
  20.     TYPE_TURRET,
  21.     TYPE_ROBOT,
  22.     TYPE_POWERUP,
  23.     TYPE_CONTAINER,
  24. };
  25.  
  26. struct mp_data
  27. {
  28.     DWORD type,dpid,flag;
  29.     vector pos,vel,Y,Z;
  30. };
  31.  
  32. struct mp_data2
  33. {
  34.     DWORD type,from;
  35.     vector v;
  36.     float f;
  37. };
  38.  
  39. class ship : public bsp_object
  40. {    
  41.     public:
  42.  
  43.         float veldamp,maxvel;
  44.         float speedboost,speedboost0;
  45.         float shield,maxshield;
  46.         int abtime,maxabtime;
  47.         int display;
  48.         int flag,flag2,flag3;
  49.         spot_light *spot;
  50.         mesh *objmesh,*shieldmesh;
  51.         explode *exp;
  52.         light *englight;
  53.         sprite_light *enghalo;
  54.         float engpos;
  55.         vector rotvel;
  56.         vector rotforce;
  57.         float angularmaxvel,angulardamp,mousespeed,forcefactor;
  58.         vector mouserot;
  59.         int lasthitfrom,lasthittime,player,points,exptime;
  60.         bsp_object expcam;
  61.         vector hitcolor,invencolor,killcolor;
  62.         float invistransp;
  63.         int ng,firesel;
  64.         gun *g[9];
  65.         light_vertex dynlights;    
  66.         vector dynlight;
  67.  
  68.     mesh *get_mesh() { return objmesh; };
  69.     int step(int dt);
  70.     void draw();
  71.     int get_custom_param_desc(int i,param_desc *pd);
  72.     int message(vector& p,float rad,int msg,int param,void *data);
  73.     mesh *ray_intersect(vector& ro,vector& rd,vector& ip,float& dist,int &facenum,float rad);
  74.  
  75.     void draw_game_status();
  76.     void check_keys(int time_step);
  77.     void mp_send_pos(int msgtype,int msgflag);
  78.  
  79.     inline bsp_object *clone() 
  80.     {
  81.         ship *s=new ship;
  82.         *s=*this;
  83.         s->source=this;
  84.         return s; 
  85.     };
  86.     ship();
  87. };
  88.  
  89. class powerup : public bsp_object
  90. {
  91. public:
  92.  
  93.     mesh *objmesh;
  94.     light *l;
  95.     int value;
  96.     int valuetype;
  97.     int mode;
  98.     dyn_sound *sndget;
  99.  
  100.     mesh *get_mesh() { return objmesh; };
  101.     int step(int dt);
  102.     void draw();
  103.     int get_custom_param_desc(int i,param_desc *pd);
  104.  
  105.     void powerup_get(ship *s);
  106.  
  107.     inline bsp_object *clone() 
  108.     { 
  109.         powerup *p=new powerup;
  110.         *p=*this;
  111.         p->source=this;
  112.         return p;
  113.     };
  114.  
  115.     powerup()
  116.     { type=TYPE_POWERUP; }
  117. };
  118.  
  119. class turret : public bsp_object
  120. {
  121. public:
  122.     mesh *base,*tube;
  123.     gun *g;
  124.     float fireang;
  125.     int firedelay;
  126.     float lookrange;
  127.     explode *exp;
  128.     float shield;
  129.     vector dynlight;
  130.     float enemydist;
  131.     bsp_object *enemy;
  132.     float rotvel;
  133.     local_system tubels;
  134.  
  135.     mesh *get_mesh() { return base; };
  136.     void init();
  137.     int step(int dt);
  138.     void draw();
  139.     int get_custom_param_desc(int i,param_desc *pd);
  140.     int message(vector& p,float rad,int msg,int param,void *data);
  141.     mesh *ray_intersect(vector& ro,vector& rd,vector& ip,float& dist,int &facenum,float rad);
  142.  
  143.     inline bsp_object *clone() 
  144.     { 
  145.         turret *t=new turret;
  146.         *t=*this;
  147.         t->source=this;
  148.         return t;
  149.     };
  150.  
  151.     turret()
  152.     { type=TYPE_TURRET; }
  153. };
  154.  
  155. class robot : public bsp_object
  156. {
  157. public:
  158.     mesh *objmesh;
  159.     mesh *shieldmesh;
  160.     gun *g;
  161.     float lookrange;
  162.     float lookangle;
  163.     float maxvel;
  164.     float rotvel;
  165.     float fireang;
  166.     float mindist;
  167.     explode *exp;
  168.     float shield;
  169.     vector shieldcolor;
  170.  
  171.     vector dynlight;
  172.     bsp_object *enemy;
  173.     vector enemylastpos;
  174.     float enemydist;
  175.     int flag;
  176.     int lasthittime;
  177.  
  178.     mesh *get_mesh() { return objmesh; };
  179.     void init();
  180.     int step(int dt);
  181.     void draw();
  182.     int get_custom_param_desc(int i,param_desc *pd);
  183.     int message(vector& p,float rad,int msg,int param,void *data);
  184.     mesh *ray_intersect(vector& ro,vector& rd,vector& ip,float& dist,int &facenum,float rad);
  185.  
  186.     inline bsp_object *clone() 
  187.     { 
  188.         robot *tmp=new robot;
  189.         *tmp=*this;
  190.         tmp->source=this;
  191.         return tmp;
  192.     }
  193.  
  194.     robot()
  195.     { type=TYPE_ROBOT; dynlight.null(); enemy=0; flag=0; lasthittime=0; }
  196. };
  197.  
  198. class container : public bsp_object
  199. {
  200. public:
  201.     mesh *objmesh;
  202.     explode *exp;
  203.     powerup *p;
  204.     float shield;
  205.     vector dynlight;
  206.  
  207.     mesh *get_mesh() { return objmesh; };    
  208.     void init();
  209.     int step(int dt);
  210.     void draw();
  211.     int get_custom_param_desc(int i,param_desc *pd);
  212.     int message(vector& p,float rad,int msg,int param,void *data);
  213.     mesh *ray_intersect(vector& ro,vector& rd,vector& ip,float& dist,int &facenum,float rad);
  214.  
  215.     inline bsp_object *clone() 
  216.     { 
  217.         container *tmp=new container;
  218.         *tmp=*this;
  219.         tmp->source=this;
  220.         return tmp;
  221.     }
  222.  
  223.     container()
  224.     { type=TYPE_CONTAINER; dynlight.null(); }
  225. };
  226.  
  227. class ship_desc : public class_desc
  228. {
  229. public:
  230.     void *create() { return new ship; };
  231.     char *get_name() { return "ship"; };
  232.     int get_type() { return TYPE_SHIP; };
  233. };
  234.  
  235. class powerup_desc : public class_desc
  236. {
  237. public:
  238.     void *create() { return new powerup; };
  239.     char *get_name() { return "powerup"; };
  240.     int get_type() { return TYPE_POWERUP; };
  241. };
  242.  
  243. class turret_desc : public class_desc
  244. {
  245. public:
  246.     void *create() { return new turret; };
  247.     char *get_name() { return "turret"; };
  248.     int get_type() { return TYPE_TURRET; };
  249. };
  250.  
  251. class robot_desc : public class_desc
  252. {
  253. public:
  254.     void *create() { return new robot; };
  255.     char *get_name() { return "robot"; };
  256.     int get_type() { return TYPE_ROBOT; };
  257. };
  258.  
  259. class container_desc : public class_desc
  260. {
  261. public:
  262.     void *create() { return new container; };
  263.     char *get_name() { return "container"; };
  264.     int get_type() { return TYPE_CONTAINER; };
  265. };
  266.  
  267.